
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Rotempco.Core.ORM.ADAL;
using System.Data.SqlClient;
using Rotempco.BaseClass.Objects.EntityObjects;
using Rotempco.Core.ORM.Objects;
using Rotempco.Core.ORM.Objects.Enums;
using Rotempco.Core.ORM.Logic;
using Rotempco.Core.Logic;




namespace Rotempco.BaseClass.DAL
{
    public partial class LoginUserData : ADAL<LoginUser, long>
    {
	    #region [ ADATA Implementation ]

        protected override string GetTableName()
        {
            return "LoginUser";
        }

        protected override Pair<string, string> GetIdentity()
        {
            return new Pair<string, string>("LoginUserId", SymbolExtensions.GetPropertyName((LoginUser d) => d.LoginUserId));
        }

        protected override List<ORMParameter> GetORMMapping()
        {
            List<ORMParameter> mapping = new List<ORMParameter>();
		
			mapping.Add(new ORMParameter("Name", SymbolExtensions.GetPropertyPair((LoginUser d) => d.Name)));
			mapping.Add(new ORMParameter("Email", SymbolExtensions.GetPropertyPair((LoginUser d) => d.Email)));
			mapping.Add(new ORMParameter("PasswordHash", SymbolExtensions.GetPropertyPair((LoginUser d) => d.PasswordHash)));
			mapping.Add(new ORMParameter("CreatedDate", SymbolExtensions.GetPropertyPair((LoginUser d) => d.CreatedDate)));
			mapping.Add(new ORMParameter("DeletedDate", SymbolExtensions.GetPropertyPair((LoginUser d) => d.DeletedDate), deletedProperty: true));
			mapping.Add(new ORMParameter("ChangePasswordOnNextLogin", SymbolExtensions.GetPropertyPair((LoginUser d) => d.ChangePasswordOnNextLogin)));

            return mapping;
        }

        #endregion

        #region [ GetBy ]

        public LoginUser GetSingle(bool getDeleted = false, long? loginUserId = null, string name = null, string email = null, string passwordHash = null, DateTime? createdDate = null, DateTime? deletedDate = null, bool? changePasswordOnNextLogin = null )
        {
            List<PropertyPair> parameterList = GetByParameterList(loginUserId: loginUserId, name: name, email: email, passwordHash: passwordHash, createdDate: createdDate, deletedDate: deletedDate, changePasswordOnNextLogin: changePasswordOnNextLogin);
            List<NullablePair> nullablePairList = GetNullablePairList();
            return GetBy(parameterList, getDeleted, nullablePairList: nullablePairList).SingleOrDefault();
        }

        public List<LoginUser> GetList(bool getDeleted = false, long? getFirstEntries = null, long? getLastEntries = null, long? loginUserId = null, string name = null, string email = null, string passwordHash = null, DateTime? createdDate = null, DateTime? deletedDate = null, bool? changePasswordOnNextLogin = null )
        {
            List<PropertyPair> parameterList = GetByParameterList(loginUserId: loginUserId, name: name, email: email, passwordHash: passwordHash, createdDate: createdDate, deletedDate: deletedDate, changePasswordOnNextLogin: changePasswordOnNextLogin);
            List<NullablePair> nullablePairList = GetNullablePairList();
            return GetBy(parameterList, getDeleted, getFirstEntries, getLastEntries, nullablePairList: nullablePairList);
        }

        #endregion

        #region [ Private ]

        private List<PropertyPair> GetByParameterList(long? loginUserId = null, string name = null, string email = null, string passwordHash = null, DateTime? createdDate = null, DateTime? deletedDate = null, bool? changePasswordOnNextLogin = null)
        {
            List<PropertyPair> mapping = new List<PropertyPair>();

			mapping.Add(new PropertyPair(loginUserId, SymbolExtensions.GetPropertyPair((LoginUser d) => d.LoginUserId)));
			mapping.Add(new PropertyPair(name, SymbolExtensions.GetPropertyPair((LoginUser d) => d.Name)));
			mapping.Add(new PropertyPair(email, SymbolExtensions.GetPropertyPair((LoginUser d) => d.Email)));
			mapping.Add(new PropertyPair(passwordHash, SymbolExtensions.GetPropertyPair((LoginUser d) => d.PasswordHash)));
			mapping.Add(new PropertyPair(createdDate, SymbolExtensions.GetPropertyPair((LoginUser d) => d.CreatedDate)));
			mapping.Add(new PropertyPair(deletedDate, SymbolExtensions.GetPropertyPair((LoginUser d) => d.DeletedDate)));
			mapping.Add(new PropertyPair(changePasswordOnNextLogin, SymbolExtensions.GetPropertyPair((LoginUser d) => d.ChangePasswordOnNextLogin)));

            return mapping;
        }

        private List<NullablePair> GetNullablePairList()
        {
            List<NullablePair> nullablePairList = new List<NullablePair>();



            if (nullablePairList.Count <= 0)
                return null;

            return nullablePairList;
        }

        #endregion

	}
}

